api={
    ajax:function(requestObject,url,data) {
        var obj={};
        $.ajax({
            type: requestObject,
            url: url,
            data:data,
            headers: {
                'Token':localStorage.getItem('Token')
            },
            async:false,
            success: function(data) {
                obj=data;
            }
        })
        return obj;
    },
    ajaxJson:function(requestObject,url,data) {
        var obj={};
        $.ajax({
            type: requestObject,
            url: url,
            dataType:"json",
            contentType: "application/json",
            data:JSON.stringify(data),
            headers: {
                'Token':localStorage.getItem('Token')
            },
            async:false,
            success: function(data) {
                obj=data;
            }
        })
        return obj;

    },
    uuid:function() {
        var s = [];
        var hexDigits = "0123456789abcdefghijklmnopqruvtvwxyz";
        for (var i = 0; i < 32; i++) {
            s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
        }
        s[14] = "4"; // bits 12-15 of the time_hi_and_version field to 0010
        s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01
        s[8] = s[13] = s[18] = s[23];
        var uuid = s.join("");
        return uuid;
    },
    //验证登录
    valitLogin:function () {
        let data=api.ajax('get','/user/islogin',undefined);
        return data;
    },
    //获取菜单信息
    getmenu:function() {
        let menu=api.ajax('get','/menu/getmenu',undefined);
        return menu;
    },
    //获取菜单信息
    getchildmenu:function () {
        let menuList=api.ajax('get','/menu/getmenuChildInfo',undefined);
        return menuList;
    },
    getmenubyUsermodel:function() {
        let  obj=api.ajax('get','/menu/getmenuListbyUser',undefined);
        return obj
    },
    getmenutableall:function() {
       let obj=api.ajax('get','/menu/getmenutablechildListall',undefined);
       return obj;
    },
    //新增菜单
    saveMenuModel:function(MenuModel) {
        let obj=api.ajaxJson('post','/menu/save',MenuModel);
        return obj;
    },
    //获取一个菜单
    getMenuModel:function(id) {
        let obj = api.ajax('get','/menu/getone?id='+id,undefined);
        return obj;
    },
    //获取用户列表分页
    getUserListPage:function (data) {
        let obj=api.ajaxJson('post','/user/page',data);
        return obj;
    },
    //新增用户
    saveAddUserModel:function(data) {
        let obj=api.ajaxJson('post','/user/saveuser',data);
        return obj;
    },
    //获取单个用户
    getUserModelByUid:function(id) {
        let obj=api.ajax('get','/user/getuserbyid?id='+id,undefined);
        return obj;
    },
    //更新用户
    updateUserModelById:function (data) {
        let obj=api.ajaxJson('post', '/user/updateuserbyid',data);
        return obj;
    },
    //存储角色
    saveRoleModel:function(data) {
        let obj=api.ajaxJson('post','/role/save',data);
        return obj;
    },
    //获取单个角色
    getRoleModel : function(id) {
        let obj=api.ajax('get','/role/getone?id='+id,undefined);
        return obj;
    },
    //更新角色
    updateRoleModel : function(data) {
        let obj=api.ajaxJson('post', '/role/update',data);
        return obj;
    },
    //获取部门列表
    getDeptModelList : function() {
        let obj=api.ajax('get','/dept/getlist',undefined);
        return obj;
    },
    //保存部门
    saveDeptModel:function(data) {
        let obj=api.ajaxJson('post','/dept/save',data);
        return obj;
    },
    //获取单个部门
    getDeptModelById:function (id) {
        let obj = api.ajax('get', '/dept/getone?id='+id,undefined);
        return obj;
    },
    //修改部门
    updateDepteModelById:function (data) {
        let obj=api.ajaxJson('post', '/dept/update',data);
        return obj;
    },
    //获取部门树形列表
    getDepteModelTreeList:function() {
        let obj=api.ajax('get','/dept/gettree',undefined);
        return obj;
    },
    //通过角色id获取已经授权的的菜单id列表
    getRoleMenuMenuIdlList:function(roleId) {
        let obj=api.ajax('get','/rolemenumodel/getrolemodelmennidlist?roid='+roleId,undefined);
        return obj;
    },
    //保存添加后的角色和菜单
    saveRoleMenuModel:function(data) {
        let obj=api.ajaxJson('post','/rolemenumodel/saveRoleMenuModel',data);
        return obj;
    },
    //获取角色id列表已经授权给用户的
    getRoleUserModelRoleIdsByUid: function(uid) {
        let obj=api.ajax('get','/roleusermodel/getRoleUserModelRoleIdListByUid?uid='+uid,undefined);
        return obj;
    },
    //保存添加后的用户和角色
    saveRoleuserModel:function(data) {
        let obj=api.ajaxJson('post','/roleusermodel/saveRoleUserModel',data);
        return obj;
    },
    //校验用户是否存在
    userIsExist:function (username) {
        let obj=api.ajax('get','/user/userIsExist?username='+username,undefined);
        return obj;
    },
    //退出登录
    userLogout:function () {
        let obj=api.ajax('get','/user/logout',undefined);
        return obj;
    },
    //获取用户个人信息
    getusermodelinfo:function () {
        let obj=api.ajax('get', '/user/getuserinfo',undefined);
        return obj;
    },
    //更改用户密码
    updateUserPassword:function (data) {
        let obj=api.ajaxJson('post','/user/updatepassword',data);
        return obj;
    },
    //添加定时任务
    addquartz:function(data) {
      let obj=api.ajaxJson('post','/jobmodel/save',data);
      return obj;
    }
    //定时任务获取单个
    ,getquartzone : function(id) {
        let obj=api.ajax('get','/jobmodel/getone?id='+id,undefined);
        return obj;
    },
    //更新定时任务
    updatequartz : function(data) {
        let obj=api.ajaxJson('post', '/jobmodel/update',data);
        return obj;
    },
    //字典获取单个通过id
    getDictibyId:function(id) {
        let obj=api.ajax('get','/dicti/getone?id='+id,undefined);
        return obj;
    },
    //添加字典
    saveDicti:function (data) {
        let obj=api.ajaxJson('post','/dicti/save',data);
        return obj;
    },
    //修改字典
    updateDictiById : function(data) {
        let obj = api.ajaxJson('post', '/dicti/update',data);
        return obj;
    },
    //保存菜单
    saveChannel:function(data){
        let obj=api.ajaxJson('post', '/channel/save',data);
        return obj;
    },
    //获取栏目列表
    getchannelList : function(data) {
        let obj=api.ajaxJson('post','/channel/childmainlist',data);
        return obj;
    },
    //获取单个栏目
    getchannelone:function (id) {
        let obj=api.ajax('get','/channel/getone?id='+id,undefined);
        return obj;
    },
    //更新栏目
    updatechannel:function(data) {
        let obj=api.ajaxJson('post','/channel/update',data);
        return obj;
    },
    //获取栏目树
    getchanneltreelist:function(data) {
        let obj =api.ajaxJson('post','/channel/childlist',data);
        return obj;
    },
    //保存内容
    saveContent:function(data) {
        let obj =api.ajaxJson('post','/title/save',data);
        return obj;
    },
    //获取内容
    getContentExt:function(id) {
        let obj=api.ajax('get','/title/getextone?id='+id,undefined);
        return obj;
    },
    //用户下线
    removeOnline:function (username) {
        let obj=api.ajax('get','/user/removeonlineuser?username='+username,undefined);
        return obj;
    },
    //流程部署
    deployProcess:function(id) {
        let obj=api.ajax('get','/flow/deploy?id='+id,undefined);
        return obj;
    },
    //获取字段类型
    getFieldType:function(){
        let obj=api.ajax('get','/tablemodel/getfieldtype',undefined);
        return obj;
    },
    //建表
    saveTable:function (data) {
        let obj=api.ajaxJson('post','/tablemodel/save',data);
        return obj;
    }
}